<?php

namespace App\Service\Auth;

use App\Constants\ErrorCode;
use App\Service\BaseService;
use App\Model\UserProfilePersonal;

/**
 * 人工认证实名
 */
class ManualVerfyService extends BaseService
{
    protected function RoVerifyList()
    {
        return [
            'id_card_pics' => 'required|string',
            'real_name' => 'required|string',
            'id_card' => 'required|string',
        ];
    }

    public function handle()
    {
        $userId = $this->getUserId();
        $info['real_name'] = $this->request->input('real_name', '');
        $info['id_card'] = $this->request->input('id_card', '');
        $info['id_card_pics'] = $this->request->input('id_card_pics', '');

        //身份证是否认证过
        $checkIdCard = UserProfilePersonal::checkIdCard($info['id_card']);
        if ($checkIdCard) {
            return $this->setError(ErrorCode::ID_CARD_EXITS, '该身份信息已存在！');
        }

        $info['id_card_pics'] = json_encode(explode(',', $info['id_card_pics']));
        $info['vry_type'] = 1;
        // $info['flag'] = UserProfilePersonal::STATUS_ING;
        //更新私人资料
        UserProfilePersonal::updateInfo($userId, $info);
        $ret = ['result' => 1];
        // log_user_result($userId, $ret);
        return $ret;
    }
}
